
var list = function (data){
    var output = "";
    output += "<a id=\"up\"href=\"#\" onclick=\"GUI.goUp(update); return false;\">..</a><br/>";
    for (var i in data.dirs)
    {
        output += "<a href=\"#\" onclick=\"GUI.goInto('" +data.dirs[i] +"', update); return false;\"><img src=\"../WiiAmp/graphic/album.jpg\" alt=\"Album\" title=\"Album\" height=\"30\" width=\"30\">" + data.dirs[i] + "</a><br/>";
    }
    for (var i in data.files)
    {
        output += "<a href=\"#\" onclick=\"GUI.setClampPath('" +data.files[i] +"', update); return false;\"><img src=\"../WiiAmp/graphic/clamp.jpg\" alt=\"ClAmp\" title=\"ClAmp\" height=\"30\" width=\"30\">" + data.files[i] + "</a><br/>";
    }   document.getElementById("output").innerHTML = output;
}

var drives = function (data){
    var output = "";
    for (var i in data){
        output += "<a href=\"#\" onclick=\"GUI.setDrive('" +data[i] +"', update); return false;\">" + data[i] + "</a><br/>";
    }
    document.getElementById("output").innerHTML = output;
}


var update = function(data){
	if (data=="ok"){
		GUI.getClampPathFiles(list);
	} else {
		GUI.getDrives(drives);
	}
}

function updateTitle(){
	Player.getTitle(rep);
}

var rep = function(data) {
		document.getElementById("Title").innerHTML =data;
		setTimeout("updateTitle()",2000)
}

function updateTime(){
	Player.getTime(reply);
}

var reply = function(data) {
		document.getElementById("Time").innerHTML =data;
		setTimeout("updateTime()",1000)
}

function togglePlaylist(){
  if (document.getElementById("output").style.display != "none")
    (document.getElementById("output").style.display = "none");
  else
   	document.getElementById("output").style.display = "block";
}


function togglePlayPause(){
  if ((document.getElementById("play").style.display != "none")&& (document.getElementById("pause").style.display != "none"))
    (document.getElementById("pause").style.display = "none");
  else
  {
  	if (document.getElementById("play").style.display != "none")
  	{
   		document.getElementById("play").style.display = "none";
		document.getElementById("pause").style.display = "block";
  	}
  	else
  	{
		document.getElementById("pause").style.display = "none";	
   		document.getElementById("play").style.display = "block";  	
  	}
  }
}
